﻿
Partial Class admin_Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim unilabel As Label = LoginView1.FindControl("uniLabel")
        Dim membercount As Label = LoginView1.FindControl("membersLabel")

        If Roles.IsUserInRole("Role_Super_Admin") Then
            Dim admincount As Label = LoginView1.FindControl("LoginView2").FindControl("adminLabel")
            unilabel.Text = "Global"
            membercount.Text = ACSService.getMembersCount()
            admincount.Text = ACSService.getAdminRequestCount()
        ElseIf Roles.IsUserInRole("Role_Uni_Admin") Then

            Dim uni_id As Integer = ACSService.getAdminUni(Membership.GetUser().ProviderUserKey.ToString())
            Dim uni_name As String = ACSService.getUniName(uni_id)

            membercount.Text = ACSService.getMembersCount(uni_id)
            'admincount.Text = "4"
            unilabel.Text = uni_name
        End If
    End Sub

    Public Shared Function getUnappedAdminCount() As Integer
        Dim count As Integer = 0
        Dim users As MembershipUserCollection = Membership.GetAllUsers()
        Dim unapprovedUsers As New MembershipUserCollection()
        For Each u As MembershipUser In users
            If Not u.IsApproved Then
                count += 1
            End If
        Next
        Return count
    End Function

    Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim panel As Panel = LoginView1.FindControl("Login1").FindControl("Panel1")
        panel.Visible = True
    End Sub
End Class
